refactor: Extract NuGet upload logic to shared helper#1465
Conversation
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Extract duplicated NuGet package upload logic from UploadPackagesToNugetModule and UploadPackagesToLocalNuGetModule into a new NugetUploadHelper class. Fixes #1459 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
SummaryExtracts duplicated NuGet package upload logic into a shared helper class to reduce code duplication. Critical Issues1. Compilation Error - Type Mismatch in UploadPackagesToLocalNuGetModule.csLocation: src/ModularPipelines.Build/Modules/LocalMachine/UploadPackagesToLocalNuGetModule.cs:26 The code passes Current code: source: localRepoLocation.Value.AssertExists()!,Should be: source: localRepoLocation.Value.AssertExists().Path,Or convert the Folder to string appropriately based on how the original code worked. 2. Missing Null Check for API KeyLocation: src/ModularPipelines.Build/Modules/UploadPackagesToNugetModule.cs:40-48 The original code had The null check should be preserved before calling the helper, since uploading to nuget.org requires an API key: ArgumentNullException.ThrowIfNull(_nugetSettings.Value.ApiKey);
return await NugetUploadHelper.UploadPackagesAsync(
context,
packagePaths.Value!,
source: "https://api.nuget.org/v3/index.json",
apiKey: _nugetSettings.Value.ApiKey,
cancellationToken);SuggestionsNone - the refactoring approach is sound once the critical issues are fixed. Verdict |
- Fix UploadPackagesToLocalNuGetModule.cs: Use .Path property on Folder object when passing to source parameter (fixes type mismatch) - UploadPackagesToNugetModule.cs already has the required null check for API key at line 39 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
SummaryExtracts duplicated NuGet package upload logic into a shared helper class to reduce code duplication. Critical IssuesMissing Null Check for API KeyLocation: src/ModularPipelines.Build/Modules/UploadPackagesToNugetModule.cs:40-48 The original code had The null check should be preserved before calling the helper, since uploading to nuget.org requires an API key. The validation ensures fast-fail with a clear error message rather than failing later during the push operation. Required fix: Keep the Previous Review StatusThe previous automated review incorrectly identified a compilation error in UploadPackagesToLocalNuGetModule.cs. Upon inspection, the code correctly includes The null check issue identified in the previous review is valid and must be addressed. Verdict |
Summary
NugetUploadHelperclassUploadPackagesToNugetModuleandUploadPackagesToLocalNuGetModuleto use the shared helperChanges
src/ModularPipelines.Build/Helpers/NugetUploadHelper.cswith a configurableUploadPackagesAsyncmethod that acceptssourceand optionalapiKeyparametersFixes #1459
Test plan
🤖 Generated with Claude Code